package com.seecen.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.seecen.common.BaseResponse;
import com.seecen.common.ResultUtils;
import com.seecen.exception.ErrorCode;
import com.seecen.pojo.entity.ItemType;
import com.seecen.service.ItemTypeService;
import com.seecen.mapper.ItemTypeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 17549
* @description 针对表【allmaster_item_type(物品类型表)】的数据库操作Service实现
* @createDate 2025-10-21 14:18:55
*/
@Service
@Slf4j
public class ItemTypeServiceImpl extends ServiceImpl<ItemTypeMapper, ItemType>
        implements ItemTypeService {

    @Override
    public BaseResponse<List<ItemType>> getItemTypes() {
        try {
            QueryWrapper<ItemType> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("is_enabled", 1)
                    .eq("is_deleted", 0)
                    .orderByAsc("item_id");

            List<ItemType> itemTypes = this.list(queryWrapper);
            return ResultUtils.success(itemTypes);

        } catch (Exception e) {
            log.error("获取物品类型列表失败", e);
            return new BaseResponse<>(ErrorCode.OPERATION_ERROR);
        }
    }
}




